﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RoadTeam.SysInterface;
using System.Data;
using RoadTeam.Model;
using RoadTeam.Model.CS;
using RoadTeam.Enums;

namespace RoadTeam.CsSystem.CS
{
    class CsInspectHouse : ICsInspectHouse
    {
        
        public DataTable GetInspectHouseDataFromRoadTeamSystem()
        {
            客服_收楼维修单 InspectHouse = new 客服_收楼维修单();
            SqlWhere where = new SqlWhere();
            where.SelectColumn = @"  收楼维修id,收楼维修单号,报修日期,单元编号,验房情况,单元名称,联系人,联系电话,签发人,签发日期,备注,APP标识量  ";
            where.Info = new 客服_收楼维修单() { 收楼维修id="-1" };
            return 客服_收楼维修单.Select(where, GlobalConfig.RtConnectionString);
        }

        public bool InsertInspectHouseDataToRoadTeamSystem(DataTable dt)
        {
           return 客服_收楼维修单.InsertDatatable(dt, GlobalConfig.RtConnectionString);
        }

        public DataRow GetInspectHouseIDFromSystem(String Identifier)
        {
            return GetInspectHouseIDFromSystem(Identifier, GlobalConfig.RtConnectionString);
        }

        private DataRow GetInspectHouseIDFromSystem(String Identifier, String ConStr)
        {
            客服_收楼维修单 item = new 客服_收楼维修单() { APP标识量 = Identifier };
            SqlWhere where = new SqlWhere();
            where.Info = item;
            where.SelectColumn = @" 收楼维修id,收楼维修单号 ";
           DataTable dt= 客服_收楼维修单.Select(where, ConStr);
           if (dt.Rows.Count == 0) return dt.NewRow();
           return dt.Rows[0];
        }
    }
}
